package com.compass.doctor.ui.home.adapter

import android.view.LayoutInflater
import android.view.ViewGroup
import com.compass.doctor.R
import com.compass.doctor.databinding.LayoutCareExecutedBinding
import com.compass.doctor.databinding.LayoutCareImplementedItemBinding
import com.compass.framework.adapter.BaseBindViewHolder
import com.compass.framework.adapter.BaseRecyclerViewAdapter
import com.compass.framework.glide.setUrl
import com.compass.framework.glide.setUrlCircle
import com.compass.framework.manager.DictionariesManager
import com.compass.framework.manager.UserInfoManager
import com.compass.framework.model.DrugTabItem
import com.compass.framework.model.MedicalCareOrder
import com.compass.framework.model.Message
import com.compass.framework.utils.DateUtils
import com.compass.framework.utils.ViewUtils
import com.compass.framework.utils.dpToPx
import com.compass.framework.utils.getDrawableResource

/**
 * Description： 已执行
 * Date:2023/12/11 21:55
 */
class CareExecutedAdapter(private var itemType: Int) :
    BaseRecyclerViewAdapter<MedicalCareOrder, LayoutCareExecutedBinding>() {
    override fun onBindDefViewHolder(
        holder: BaseBindViewHolder<LayoutCareExecutedBinding>,
        item: MedicalCareOrder?,
        position: Int
    ) {
        if (item == null) return
        holder.binding.apply {
            if (itemType == 1) {
                tvStatus.text = DictionariesManager.getNurseStatusValue(item.status)
            }

            if (itemType == 2) {
                tvStatus.text = DictionariesManager.getAfterStatusValue(item.status)
            }
            tvType.text = if (UserInfoManager.getUserType() == "1") "医" else "护"
            ViewUtils.setClipViewCornerRadius(imgMap, dpToPx(5))
            imgMap.setUrl(item.locationUrl)
            tvTitle.text = item.nurseName
            tvVisitTime.text = DateUtils.conversionTime(item.appointmentTime, DateUtils.FORMAT_TWO)
            item.address?.let { tvAddress.text = it.address }
            tvLocation.text = "${item.distance}km"
            tvName.text = item.patientName
            ivHead.setUrlCircle(item.patientAvatar)
            ivSex.background =
                if (item.patientSex == 1) getDrawableResource(R.mipmap.icon_male) else getDrawableResource(
                    R.mipmap.icon_female
                )
            tvAge.text = item.patientAge
            ViewUtils.setClipViewCornerRadius(imgMask, dpToPx(5))
        }
    }

    override fun getViewBinding(
        layoutInflater: LayoutInflater,
        parent: ViewGroup,
        viewType: Int
    ): LayoutCareExecutedBinding {
        return LayoutCareExecutedBinding.inflate(layoutInflater, parent, false)
    }
}